/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
 var searchInsert = function(nums, target) {
  let left = 0;
  let right = nums.length;
  while (left < right) {
      const mid = (left + right) >> 1;
      if (nums[mid] >= target) {
          right = mid;
      } else {
          left = mid + 1;
      }
  }
  return left;
};